#include <iostream>
#include <ostream>
//
// Created by Asus on 2025/4/20.
//
int main() {
    int num;
    num = 10;
    int* p;
    p = &num;
    int num2 = 20;
    int *p2 = &num2;
    std::cout << "num value is:" << num << std::endl;
    std::cout << "num address is:" << &num << std::endl;
    std::cout << "num ptr  is:" << p << std::endl;

    int& ref = num;
    std::cout << "Value of num: " << num << std::endl;
    std::cout << "Value of ref: " << ref << std::endl;
    std::cout << "Value of &ref: " << &ref << std::endl;

    // 修改引用的值，实际上就是修改 num 的值
    ref = 20;

    std::cout << "New value of num: " << num << std::endl;
    std::cout << "New value of ref: " << ref << std::endl;
    return 0;
}